package com.tjsinfo.tjsoa.mail.bo;

import java.util.List;

import com.tjsinfo.tjsoa.mail.dao.ITjsspamDao;
import com.tjsinfo.tjsoa.mail.vo.Tjsmail;
import com.tjsinfo.tjsoa.mail.vo.Tjsspam;

import com.tjsinfo.tjsoa.system.vo.TSystemUser;
/**
 * 垃圾邮件的BO
 * @author wangxiaowei
 *
 */
public class TjsSpamBo implements ITjsSpamBo{
	
	private ITjsspamDao tjsspamDao;
	private final boolean STARTTRUE=true;
	private final boolean STARFALSE=false;
	public ITjsspamDao getTjsspamDao() {
		return tjsspamDao;
	}
	public void setTjsspamDao(ITjsspamDao tjsspamDao) {
		this.tjsspamDao = tjsspamDao;
	}
	/**
	 * 定义为垃圾邮件
	 * @param 邮件ID
	 * @param 用户ID
	 * @return
	 */
	public boolean addTjsSpam(String emailid,Integer userid)
	{
		try {
			Tjsspam tjsspam = new Tjsspam();//垃圾邮件
			Tjsmail	tjsmail = new Tjsmail();
			tjsmail.setTjsmailId(emailid);
			TSystemUser tjsUser = new TSystemUser();
			
			tjsUser.setUserId(userid);
			tjsspam.setTjsmail(tjsmail);
			tjsspam.setTjsUser(tjsUser);
			tjsspamDao.save(tjsspam);
			return STARTTRUE;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return STARFALSE;
		}
	}
	/**
	 * 取消指定用户的指定邮件的垃圾邮件定义
	 * @param 邮件ID
	 * @param 用户ID
	 * @return
	 */
	public boolean canleTjsSpam(String emailid,Integer userid)
	{
		try {
			Tjsspam tjsspam = tjsspamDao.selectById(emailid);//垃圾邮件
			tjsspamDao.delete(tjsspam);
			return STARTTRUE;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return STARFALSE;
		}
	}
	/**
	 * 查找指定用户下的垃圾邮件
	 * @param userid
	 * @return
	 */
	public List selectTjsSpamUserid(Integer userid)
	{
		return  tjsspamDao.selectTjsspamByUserid(userid);
	}
}
